package com.cloud.excel;

import com.alibaba.excel.EasyExcelFactory;
import com.alibaba.excel.metadata.Sheet;
import org.springframework.stereotype.Component;

import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;

@Component
public class EasyExcelService {


    public List<ExcelCreditDO> excel(String filePath) throws Exception {
        FileInputStream inputStream = new FileInputStream(new File(filePath));
        Sheet sheet = new Sheet(1, 1, ExcelCreditDO.class);
        List<Object> readList  = EasyExcelFactory.read(inputStream, sheet);
        List<ExcelCreditDO> list = new ArrayList<ExcelCreditDO>();
        for (Object obj : readList ) {
            list.add((ExcelCreditDO) obj);
        }
        return list;
    }




}
